import { Plugin } from 'vite'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'

export default function autoImport(plugins: Plugin[]) {
    plugins.push(
        AutoImport({
            resolvers: [ElementPlusResolver()],
            imports: ['vue', 'vue-router'],
            //为true时在项目根目录自动创建
            dts: 'types/auto-imports.d.ts',
        }),
        Components({
            resolvers: [ElementPlusResolver()],
            dirs: ['src/components'],
            //组件名称包含目录，防止同名组件冲突
            directoryAsNamespace: true,
            //指定类型声明文件，为true时在项目根目录创建
            dts: 'types/components.d.ts',
        })
    )
}
